var appIdentifier = 'likit';
export var setAppIdentifier = function setAppIdentifier(newAppIdentifier) {
  appIdentifier = newAppIdentifier;
};
export var getPlatformInfo = function getPlatformInfo(appIdentifierCustom) {
  var userAgent = window.navigator.userAgent.toLowerCase();
  var ios = !!userAgent.match(/\(i[^;]+;( u;)? cpu.+mac os x/);
  var android = userAgent.indexOf('android') > -1 || userAgent.indexOf('linux') > -1 || !ios;
  var app = userAgent.indexOf("".concat((appIdentifierCustom || appIdentifier).toLowerCase(), "/")) > -1;
  var ios_app = ios && app;
  var android_app = android && app;
  var alipay = userAgent.indexOf('alipayclient/') > -1 && !app;
  var ios_alipay = ios && alipay;
  var android_alipay = android && alipay;
  var wechat = userAgent.indexOf('micromessenger/') > -1 && userAgent.indexOf('wxwork/') === -1 && !app;
  var ios_wechat = ios && wechat;
  var android_wechat = android && wechat;
  var platform;

  if (ios_app) {
    platform = 'ios_app';
  } else if (android_app) {
    platform = 'android_app';
  } else if (app) {
    platform = 'app';
  } else if (ios_alipay) {
    platform = 'ios_alipay';
  } else if (android_alipay) {
    platform = 'android_alipay';
  } else if (alipay) {
    platform = 'alipay';
  } else if (ios_wechat) {
    platform = 'ios_wechat';
  } else if (android_wechat) {
    platform = 'android_wechat';
  } else if (wechat) {
    platform = 'wechat';
  } else if (ios) {
    platform = 'ios';
  } else if (android) {
    platform = 'android';
  } else {
    platform = 'web';
  }

  var platformInfo = {
    ios: ios,
    android: android,
    app: app,
    ios_app: ios_app,
    android_app: android_app,
    alipay: alipay,
    ios_alipay: ios_alipay,
    android_alipay: android_alipay,
    wechat: wechat,
    ios_wechat: ios_wechat,
    android_wechat: android_wechat,
    platform: platform
  };
  return platformInfo;
};